<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        body>div{
            width: 500px;
            margin: 50px auto;
        }
        button{
            width:100px;
            height: 30px;
        }
    </style>
</head>
<body>
<div class="content" ms-controller="i_test">
    <br/>
    <h3>输入相应内容，点击相应按钮检验</h3>
    <div style="width: 316px;">
        <tsy:input ms-data-id="'i_value'">
            <input slot="core" class="tsy-input tsy-input-md"
                   type="text" ms-duplex="txt">
        </tsy:input>
    </div>
    <button ms-click="checkpwd">密码</button>
    <br/><br/>

    <button ms-click="checknum">数字</button>
    <br/><br/>

    <button ms-click="checkpho">电话号</button>
    <br/><br/>

    <button ms-click="checkmob">手机号</button>
    <br/><br/>

    <button ms-click="checkema">邮箱</button>
    <br/><br/>


    <button ms-click="checkmon">金钱</button>
    <span>整数或只有2为小数的数值</span>
    <br/><br/>

    <button ms-click="checkid">身份证</button>

    <br/><br/>
    <button ms-click="checkname">用户名</button>

    <br/><br/>
    <button ms-click="checkoth">其他自定义</button>
    <span>其他（type传入函数）</span>
    <br/>


</div>
<script src="../../../src/js/avalon.modern.1.5.min.js"></script>
<script>
    avalon.ready(function () {
        require(['../../plugins/CheckUp/CheckUp', '../../lib/whatInput/whatInput'], function () {
            //父元素VM
            var i_test = avalon.define({
                $id: "i_test",
                txt: "",

                checkpwd: function () {
                    CheckUp(i_test.txt, 'pwd', 'i_value');
                },
                checknum: function () {
                    CheckUp(i_test.txt, 'number', 'i_value');
                },
                checkpho: function () {
                    CheckUp(i_test.txt, 'telephone', 'i_value');
                },
                checkmob: function () {
                    CheckUp(i_test.txt, 'mobile', 'i_value');
                },
                checkema: function () {
                    CheckUp(i_test.txt, 'email', 'i_value');
                },
                checkmon: function () {
                    CheckUp(i_test.txt, 'money', 'i_value');
                },
                checkid: function () {
                    CheckUp(i_test.txt, 'id', 'i_value');
                }, 
                
                checkname: function () {
                    CheckUp(i_test.txt, 'username', 'i_value');
                },
                checkoth:function(){
                    CheckUp(i_test.txt, function(val){
                        var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
                        if (reg.test(val)) {
                            return [true, ''];
                        }
                        return [false, '不是正确的自定义的电子邮箱格式'];
                    }, 'i_value');
                }
            });
            avalon.scan();
        });
    })
</script>
</body>
</html>